﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Xpus.Website.Core.WebPage
{
	/// <summary>
	/// 表示Xpus自定义页面，处理对于*.x页面的请求。
	/// </summary>
	public class XpusPageHandler : IHttpHandler
	{
		#region IHttpHandler Members
		/// <summary>
		/// 获取一个值，该值指示其他请求是否可以使用<see cref="IHttpHandler"/>实例。
		/// </summary>
		public bool IsReusable
		{
			get
			{
				return false;
			}
		}

		/// <summary>
		/// 处理请求。
		/// </summary>
		/// <param name="context"><see cref="HttpContext"/>对象，它提供对用于为 HTTP 请求提供服务的内部服务器对象（如 Request、Response、Session 和 Server）的引用。</param>
		public void ProcessRequest(HttpContext context)
		{
			context.Response.ContentEncoding = Encoding.UTF8;
			context.Response.ContentType = "text/html";

			context.Response.Write("Raw Url: " + context.Request.RawUrl);
			context.Response.Write("<br />");
			context.Response.Write("Url: " + context.Request.Url.OriginalString);
			context.Response.Write("<br />");
			context.Response.Write("Host: " + context.Request.Url.Host);
			context.Response.Write("<br />");
			context.Response.Write("HostNameType: " + context.Request.Url.HostNameType.ToString());
			context.Response.Write("<br />");
			context.Response.Write("<br />");
			if(context.Request.UrlReferrer != null)
				context.Response.Write("Reffer: " + context.Request.UrlReferrer.OriginalString);
		}
		#endregion
	}
}
